﻿using BusinessFramework.AOP;

namespace BusinessFramework.Samples.SL
{
    [NotifyPropertyChanged]
    [Sample(@"Rules\BusinessRule", Code.BusinessRuleEntity)]
    public class BusinessRuleEntity : EntityBase<BusinessRuleEntity>
    {
        public int Value { get; set; }
        public int Value2 { get; set; }
        public int Total { get; set; }

        [RuleInit]
        public void RuleInit()
        {
#if PHONE
            Extensions.CreateBusinessRuleWithoutDependency(s => s.Value + s.Value2, s=>s.Total, (s,v)=>s.Total=v)
                .WithDependencies(s => s.Value, s => s.Value2)
                .Start();
#else

            #region Code

            Extensions.CreateBusinessRule(e => e.Value + e.Value2, e => e.Total).Start();

            #endregion

#endif
        }
    }
}